package gameObjects;

import java.io.IOException;

import logic.Coords2D;

import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import editor.Menu.OGGETTI;

public class Ruby extends Object3D{
	private static final long serialVersionUID = 2304100217L;
	private OGGETTI t;
	private Coords2D coords;
	public enum PILLCOLOR{RED,YELLOW,GREEN};
	
	public Ruby(OGGETTI t,Coords2D c) throws IOException
	{
		super(c.toString());
		this.getModel("objects/ruby.jme");
		this.coords=c;
		this.Place(c.getX()+0.5f, 0.5f, c.getY()+0.5f);
		this.model3D.setLocalScale(0.0025f);
		this.t=t;
		this.addTexture();
		System.out.println("RUBY :" + this.getName());
	}
	
	private void addTexture()
	{
		if (t.equals(OGGETTI.RUBYBLUE))
			this.texture.setTexture("textures/blue_color.jpg", new Vector3f(1, 1, 1), false);
		if (t.equals(OGGETTI.RUBYGREEN))
			this.texture.setTexture("textures/green_color.jpg", new Vector3f(1, 1, 1), false);
		if (t.equals(OGGETTI.RUBYRED))
			this.texture.setTexture("textures/red_color.jpg", new Vector3f(1, 1, 1), false);
		this.texture.setTextureManager(this.getChildById(0));
	}
	
	private void Place(float x, float y, float z)
	{
		this.model3D.setLocalTranslation(x, y, z);
	}
	
	public void update(float tpf)
	{
		Quaternion rot = new Quaternion();
        Vector3f axis = new Vector3f( 0, 1, 0 ).normalizeLocal();
		rot.fromAngleNormalAxis( 5.5f * tpf, axis );
		this.model3D.getLocalRotation().multLocal(rot);
	}
	public Coords2D getCoords()
	{
		return this.coords;
	}
}
